<template>
  <div :class="`news ${className}`" v-if="news && news > 0">
    <span v-if="news <= max">{{ news }}</span>
    <span v-else>
      <van-icon class="icon" v-if="styles === 'ellipsis'" name="ellipsis" />
      <span v-else>{{ '99+' }}</span>
    </span>
  </div>
</template>

<script>
export default {
  props: {
    news: {
      type: [Number, String]
    },
    styles: {
      type: String,
      default: 'ellipsis'
    },
    className: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      max: 99
    }
  }
}
</script>

<style lang="less" scoped>
.news {
  position: absolute;
  top: 0px;
  right: 0;
  box-sizing: border-box;
  min-width: 18PX;
  padding: 0 3PX;
  color: #fff;
  font-weight: 500;
  font-size: 12PX;
  font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
  height: 18PX;
  line-height: 18PX;
  text-align: center;
  background-color: #ea4d2e;
  // border: 1px solid #fff;
  border-radius: 50%;
  -webkit-transform: translateX(50%);
  transform: translateX(30%);
  -webkit-transform-origin: 100%;
  transform-origin: 100%;
}

.icon {
  vertical-align: middle;
}
</style>